package com.deer.wms.base.system.web.bill;

import com.deer.wms.base.system.model.bill.*;
import com.deer.wms.base.system.model.zh.ElectricBoxDetail;
import com.deer.wms.base.system.service.bill.BillOutMesService;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 李帅辰
 * @date 2021/6/24 12:43
 */
@Controller
@RequestMapping("/out/billOutMes")
public class BillOutMesController extends BaseController {


    private String prefix = "out/billOutMes";

    @Autowired
    private BillOutMesService billOutMesService;
    /**
     * 导出列表
     */
    @RequiresPermissions("out:billOutMes:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BillOutMes billOutMes) {
        List<BillOutMes> list = billOutMesService.findBillOutMesList(billOutMes);
        ExcelUtil<BillOutMes> util = new ExcelUtil<BillOutMes>(BillOutMes.class);
        return util.exportExcel(list, "MES出库管理");
    }
    /**
     * 导出列表
     */
    @RequiresPermissions("out:billOutMes:partExcel")
    @PostMapping("/partExcel")
    @ResponseBody
    public AjaxResult partExcel(@RequestParam  String ids) {
        List<BillOutMes> byIds = billOutMesService.findByIds(ids);
        // List<BillInSapDto> billInSapList = billInSapService.findBillInSapDtoList(billInSapCriteria);
        ExcelUtil<BillOutMes> util = new ExcelUtil<BillOutMes>(BillOutMes.class);
        return util.exportExcel(byIds, "MES出库管理");
    }
    //打印
    @RequestMapping("print")
    public String print(@RequestParam String ids, Model model) {

        //System.out.println(ids);
        List<BillOutMes> byIds = billOutMesService.findByIds(ids);
        model.addAttribute("byids", byIds);


        return prefix + "/print";
    }

    @RequiresPermissions("out:billOutMes:view")
    @GetMapping()
    public String billOutMes() {
        return prefix + "/billOutMes";
    }

    /**
     * MES出库管理接口,MES叫料的集合
     * @author 申紫微
     * @date 9:11 2021/7/6
     * @params null
     * @return null
     **/
    //@RequiresPermissions("out:billOutMes:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo findList(BillOutMes billOutMes){
        startPage();
        List<BillOutMes> list = billOutMesService.findBillOutMesList(billOutMes);
        return getDataTable(list);
    }


    @GetMapping("/detail")
    public String detail() {
        return prefix + "/detail";
    }

    @PostMapping("/findBillOutMesBybillOutMesId")
    @ResponseBody
    public BillOutMes findBillOutMesBybillOutMesId(Integer billOutMesId) {
        return billOutMesService.findBillOutMesBybillOutMesId(billOutMesId);
    }

}
